﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TimKen.App;
using TimKen.BussLogic;

namespace TimKen.Web.Admin.Gift {
    public partial class GiftInfo_Edit : AdminPage{
        protected void Page_Load(object sender, EventArgs e) {
            ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(this.ddlLanguage);
            if (!Page.IsPostBack) {
                BindResources();
                BindData();
            }
        }

        protected void BindResources() {
            ddlLanguage.Items.Clear();
            ListItem li_ZH = new ListItem("简体中文", "1");
            ListItem li_EN = new ListItem("English", "2");
            ddlLanguage.Items.Add(li_ZH);
            ddlLanguage.Items.Add(li_EN);
            btnConfirm.Text = GetLangString("Save");
        }

        private void BindData() {
            string LanguageID = this.ddlLanguage.SelectedValue;

            ArticleManager am = new ArticleManager();
            List<DataEntity.Article> articleList = am.GetModelList("  TypeID=8 AND LanguageID=" + LanguageID);
            DataEntity.Article culture;
            culture = articleList[0];

            this.fckContent.Value = culture.Content;
        }

        protected void btnConfirm_Click(object sender, EventArgs e) {
            string LanguageID = this.ddlLanguage.SelectedValue;
            ArticleManager am = new ArticleManager();
            List<DataEntity.Article> articleList = am.GetModelList("  TypeID=8 AND LanguageID=" + LanguageID);
            DataEntity.Article culture;
            culture = articleList[0];
            culture.Content = this.fckContent.Value;
            am.Update(culture);
            BindData();

        }
        protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e) {
            BindData();
        }
    }
}
